<?php

namespace app\controllers\device;

use app\common\base\CommonController;

class DeviceLogsController extends CommonController
{
    public function actionRecord()
    {
        $this->rules = [
            [['operationId', 'deviceId', 'olddata', 'newdata'], 'required'],
            [['deviceId', 'olddata', 'newdata', 'operationId'], 'integer'],
        ];
        $inputs = $this->validate();
        $info = parent::callModuleService('log', 'DeviceLogsService', 'record', $this->userInfo->id, $inputs['operationId'], $inputs['deviceId'], $inputs['olddata'], $inputs['newdata']);

        return [
            'message' => $info,
        ];
    }

    public function actionFind()
    {
        $this->rules = [
            [['operationId', 'userId', 'deviceId', 'timeStart', 'timeEnd'], 'required'],
            [['deviceId', 'operationId', 'userId'], 'integer'],
            [['timeStart', 'timeEnd'], 'string'],
        ];
        $inputs = $this->validate();
        $info = parent::callModuleService('log', 'DeviceLogsService', 'find', $inputs['userId'], $inputs['operationId'], $inputs['deviceId'], $inputs['timeStart'], $inputs['timeEnd']);
        return $info;
    }
}
